package com.etc.order.frontend.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class StaticFilter implements Filter {
    private static final Logger logger = LoggerFactory.getLogger(StaticFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        logger.info("processing link:{}", ((HttpServletRequest)request).getRequestURI());
        request.getRequestDispatcher(((HttpServletRequest)request).getRequestURI().replace("/static", "")).forward(request, response);
    }

    @Override
    public void destroy() {

    }
}
